package com.l.web.master.system.dictionary;

import com.mongodb.BasicDBObject;
import org.bson.Document;
import org.l.qiao.AbstractCollectionDAO;
import org.l.qiao.Cluster;
import org.springframework.stereotype.Repository;

@Repository
public class DictionaryDao extends AbstractCollectionDAO {
    public static final String COLLECTION = "c_dictionary";

    public DictionaryDao() {
        super(COLLECTION);
    }

    public Cluster findById(int id) {
        BasicDBObject bdb = new BasicDBObject();
        bdb.put(Dictionary.ID, id);
        Document document = this.getCollection().find(bdb).first();

        if (document != null) {
            return new Cluster(document);
        } else {
            return null;
        }
    }
}
